package pl.maciejziarko.mshare.domain;

import pl.maciejziarko.mshare.utils.Check;

/**
 * @author Maciej Ziarko
 */
public final class Role {

    private String name;
    private String description;

    public Role(String name) {
        Check.notEmpty(name, "Role name cannot be empty.");

        this.name = name;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Role role = (Role) o;

        if (name != null ? !name.equals(role.name) : role.name != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return name != null ? name.hashCode() : 0;
    }
}
